<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>隧道地图</title>
    <style>
        html, body {
            padding: 0px;
            margin: 0px;
        }

        html, body, #map {
            width: 100%;
            height: 100%;
        }

        .anchorBL {
            display: none;
        }

    </style>
</head>
<body>
<div id="map"></div>
<script src="js/jquery.min.js"></script>
<script type="text/javascript"
        src="//api.map.baidu.com/api?v=2.0&ak=0Ad9b6990afa90551082b9d343405152"></script>
<script>
    var map = new BMap.Map("map");
    var sumLng = 0;
    var sumLat = 0;
    $.get("tunnels", function (result) {
        for (var i in result.data) {
            var station = result.data[i];
            if (station.lng && station.lat) {
                sumLng += station.lng;
                sumLat += station.lat;
                var point = new BMap.Point(station.lng, station.lat);
                var marker = new BMap.Marker(point);
                var label = new BMap.Label(station.name, {offset: new BMap.Size(20, -10)});
                marker.setLabel(label);
                map.addOverlay(marker);
            }
        }
        var center = new BMap.Point(sumLng / result.data.length, sumLat / result.data.length);
        map.centerAndZoom(center, 12);// 初始化地图,设置城市和地图级别。
        map.enableScrollWheelZoom(true);
    });
</script>
</body>
</html>